Fix ExplicitTaylor fsallast aliasing to state buffer - #3975
Open
singhharsh1708 wants to merge 1 commit into
Open
Fix ExplicitTaylor fsallast aliasing to state buffer#3975singhharsh1708 wants to merge 1 commit into
singhharsh1708 wants to merge 1 commit into
Conversation
singhharsh1708
force-pushed
the
fix-explicittaylor-fsallast-aliasing
branch
from
July 30, 2026 14:58
6ad45a4 to
7db67ee
Compare
get_fsalfirstlast for ExplicitTaylorCache and ExplicitTaylorAdaptiveOrderCache returned (cache.u, cache.u), aliasing the FSAL buffer to the state itself. The generic auto-dt heuristic writes an extra f evaluation into fsallast, so this made that call f(u, u, p, t), corrupting u mid-evaluation for RHS functions that read from u after writing to du. On the Pleiades N-body problem several bodies share identical initial velocity components, so the corruption produces coincident positions and a 0/0 division in the pairwise force term - default-adaptive ExplicitTaylor(order=Val(6)) returns retcode=DtNaN after one step. Give both caches an independent scratch buffer instead, matching ExplicitTaylor2Cache's existing pattern.
singhharsh1708
force-pushed
the
fix-explicittaylor-fsallast-aliasing
branch
from
July 31, 2026 20:09
7db67ee to
72e7246
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
get_fsalfirstlastforExplicitTaylorCacheandExplicitTaylorAdaptiveOrderCachereturned(cache.u, cache.u), aliasing the FSAL buffer to the state buffer itself.The generic auto-dt heuristic (
ode_determine_initdtin OrdinaryDiffEqCore) writes an extrafevaluation into whichever bufferfsallastpoints to. With this aliasing, that call effectively becomesf(u, u, p, t), which corruptsumid-evaluation for any RHS that reads fromuafter writing todu(a normal, valid in-place pattern).On the Pleiades N-body problem (
ODEProblemLibrary.prob_ode_pleiades), several bodies share identical initial velocity components, so the corruption produces coincident positions and a0/0division in the pairwise inverse-cube force term. Default-adaptiveExplicitTaylor(order=Val(6))returnsretcode=DtNaNafter exactly one step; supplying a startingdtwas previously the only workaround.Fix: give both caches an independent scratch buffer instead of aliasing
cache.u, matchingExplicitTaylor2Cache's existing(cache.k1, cache.k1)pattern for the same "FSAL not really used" situation.Verification
ExplicitTaylor(order=Val(6))on Pleiades under fully default settings (nodtoverride):retcode=Success, 587 steps, matches the previousdt-workaround result to 4-5 significant figures.OrdinaryDiffEqTaylorSeriesCore test group passes unchanged.Known follow-up (not fixed here)
ExplicitTaylorAdaptiveOrder()had the identical aliasing bug and no longer crashes withDtNaNafter this fix, but separately has its own pre-existing error-estimation bug that this fix exposes (previously masked by the crash). Filed as #3976 rather than fixed here. Marked@test_brokenin the added test.Test plan
ExplicitTaylor(order=Val(6))solves Pleiades under default adaptive settings without adtoverrideOrdinaryDiffEqTaylorSeriespasses with no regressions